package com.ouken.tool;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;

import com.gen.tool.PlayerInfo;
import com.ouken.com.R;

import android.app.Activity;
import android.app.Application;
import android.graphics.Bitmap;
import android.media.AudioManager;
import android.media.SoundPool;

public class MyApp extends Application {
	private String userEmail;
	private String passwd;
	private String nickName;
	private String mac;
	private Bitmap img;
	private String imgToString;
	//private Boolean music;
	private List<Activity> listActivities;
	
	private String roomName;
	private String activeMem;
	private String limitedMem;
	private String totalScore;
	private ArrayList<PlayerInfo> playerInfo = new ArrayList<PlayerInfo>();
	
	private int refreshGRcounter = 0;
	
	
	public String getUserEmail() {
		return userEmail;
	}

	public void setUserEmail(String userEmail) {
		this.userEmail = userEmail;
	}

	public String getPasswd() {
		return passwd;
	}

	public void setPasswd(String passwd) {
		this.passwd = passwd;
	}

	public String getNickName() {
		return nickName;
	}

	public void setNickName(String nickName) {
		this.nickName = nickName;
	}

	public String getMac() {
		return mac;
	}

	public void setMac(String mac) {
		this.mac = mac;
	}

	public Bitmap getImg() {
		return img;
	}

	public void setImg(Bitmap img) {
		this.img = img;
		
		ByteArrayOutputStream out = new ByteArrayOutputStream();   
		img.compress(Bitmap.CompressFormat.PNG, 100, out);
        
        
        try {   
            out.flush();   
            out.close();   
        } catch (IOException e) {   
            e.printStackTrace();   
        }  
        
        byte[] bb = out.toByteArray();
        String test ="";
        BigInteger bigInt = new BigInteger(1, bb);
        test = bigInt.toString(16);
        
        setImgToString(test);
        
	}

	public String getImgToString() {
		return imgToString;
	}

	private void setImgToString(String imgToString) {
		this.imgToString = imgToString;
	}

	/*public Boolean getMusic() {
		return music;
	}

	public void setMusic(Boolean music) {
		this.music = music;
	}*/

	

	public List<Activity> getListActivities() {
		return listActivities;
	}

	public void setListActivities(List<Activity> listActivities) {
		this.listActivities = listActivities;
	}
	
	public void addActivity(Activity activity){
		listActivities.add(activity);
	}
	public void killAllActivities(){
		for(int i= 0;i<listActivities.size();i++){
			listActivities.get(i).finish();
		}
	}
	public String getRoomName() {
		return roomName;
	}
	
	public void setRoomName(String roomName){
		this.roomName = roomName;
	}
	
	public String getMem(){
		return activeMem+ "/" + limitedMem;
	}
	
	public void setMem(String actNum, String limMem){
		this.activeMem = actNum;
		this.limitedMem = limMem;
	}

	public int getRefreshGRcounter(){
		return refreshGRcounter;
	}
	
	public void setGRcounterZ(){
		this.refreshGRcounter = 0;
	}
	
	public void addGRcounter(){
		this.refreshGRcounter++;
	}
	
	public void setTotalScore(String totalScore){
		this.totalScore = totalScore;
	}

	public String getTotalScore(){
		return this.totalScore;
	}
	public ArrayList<PlayerInfo> getPlayerList(){
		return this.playerInfo;
	}
	public PlayerInfo getPlayerByNum(int num){
		return this.playerInfo.get(num);
	}
	
	public void setPlayerList(ArrayList<PlayerInfo> playerInfo){
		this.playerInfo = playerInfo;
	}
	
	public void iniPlayerInfo(PlayerInfo playerInfo){
		this.playerInfo.add(playerInfo);
	}
	
	public void setPlayerInfo(int num, PlayerInfo playerInfo){
		this.playerInfo.set(num, playerInfo);
	}
	
	public void setPlayerInfoState(int playerNum, String value){
		this.playerInfo.get(playerNum).setState(value);
	}
	public void setClearPlayerInfo(){
		this.playerInfo.clear();
	}

}
